package org.nokatag.system;

import java.sql.Connection;
import java.util.List;
import java.util.Map;

import org.nokatag.dbgrid.SubGrid;

public class DBCon {

	public static Connection getCon() {
		Connection con = null;
		try {
			con = ServletNokaContext.getConnection();//(Connection) request.getAttribute(Concest.DATA_BASE_REQUEST);
		} catch (Exception se) {

		}
		try {
			if (con == null) {
				NLoadFun nloadFun = new NLoadFun();
				DataConnection action = (DataConnection)nloadFun.getBean(Concest.CONNECTION);
				con = action.getConnection();
			}
			con.setAutoCommit(true);
		} catch (Exception e) {
			BugInfoWrint.Print("noka connection is : " + "file:"+ Concest.ROOTDIR + "/WEB-INF/classes" + " " + e);
		}
		return con;

	}

	public static String getCon(String path, Integer i,Map<String, Object> map, List<String> Cellname) {
		try {
			NLoadFun nloadFun = new NLoadFun();
			SubGrid action = (SubGrid)nloadFun.getBean(path);
			return action.getBody(i, map, Cellname);
		} catch (Exception e) {
			BugInfoWrint.Print("noka connection is : " + "file:"+ Concest.ROOTDIR + "/WEB-INF/classes" + " " + path);
		}
		return null;

	}
}
